
#ifndef AUTO_INTER_FILE_H
#define AUTO_INTER_FILE_H

#include <QFile>
/*
exe line should be format as " command: format : parameter ", list example:
wait: time : 2 ; means wait 200ms here,the value is count of 100ms.
wait: read : please input your command ; means wait until read string " please input your command".
write: str : change some thing ; means input string "change some thing" .
write: hex : abc23 ; means input hex 0xab 0xc2 0x03.
write: file : D:\QtProject?\test.data ; meas input the file data of D:\QtProject?\test.data .
*/
class cmdList;
/*			command data		*/
enum cmdType
{
    INVALID_CMD,
    WAIT_TIME,
    WAIT_READ,

    WAIT_WRITE_GAP,

    WRITE_STR,
    WRITE_HEX,
    WRITE_FILE
};
union cmdParam
{
    QString * str;
    int     count;
};

struct ExeCmdData
{
    cmdType type;
    cmdParam param;
};
/*			loop data				*/
struct LoopCmdData
{
    cmdList * sublist;
    int 	count;
	int index;
};
/*			list node				*/
enum ListNodeType
{
	INVALID_TYPE,
        AUTO_INTER_CMD,
	LOOP_SUB_CMD
};

union ListNodeData
{
	ExeCmdData  CmdData;
	LoopCmdData LoopData;
	
};

struct cmdNode
{
	ListNodeType type;
	ListNodeData data;
};
/*			list				*/
class cmdList
{
public :
    	cmdList();
    	~cmdList();
        cmdList * GetFirstExeCmd();
	cmdList * GetRoot();
	cmdList * GetNext();
	bool CheckValid();
    	cmdList * head;//head loop
    	cmdList * next;
	cmdNode node;
	QString 	SourceString;
};

class autointerfile : public QFile

{
    Q_OBJECT
public:
    autointerfile();
    ~autointerfile();
    cmdList * BuildCmdListFromFile(QString fileName);

private:
    bool checkValid();
    cmdList * buildSubCmdList(cmdList * pHead);

public :
	QString m_endFix;
    QString m_errorinfo;

};














#endif
